<?php

namespace Beerus\Modules\Designer\Actions;

use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Doraemon\model\DesignerPackage;


class OffLineCombo extends RowAction
{
    public $name = '下线套餐';
    const TOAST_ALERT = '确认将该套餐下线嘛?下线后套餐将无法在官网上展示!';

    public function handle($id)
    {
        $update_data['status'] = DesignerPackage::STATUS_CLOSE;
        $ka_result = DesignerPackage::update($update_data, [
            'id' => $id
        ]);
        if ($ka_result){
            return $this->response()->success('成功下线套餐(*^__^*)')->refresh();
        }else{
            return $this->response()->error('下线套餐失败,请稍后重试o(TωT)o');
        }

    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}
